import http from '@/base/http';
import { FriendVO } from './types';
import { HttpResponse } from '../types';

/**
 * userInfo
 */
enum Friend {
  friendList = '/friend/list', // 好友列表
  nearbyFriendList = '/wx/user/nearby/getNearbyFriend', // 好友列表
  remark = '/friend/remark', // 备注
  publicFriendList = '/wx/user/publicFriends/page', // 公开豹友名单
  applications = '/friend/applications', // 获取好友申请列表
  searchFriend = '/friend/search', // 搜索好友
  searchPublicFriend = '/wx/user/publicFriends/search', // 搜索公开豹友名单
  friendAdd = '/friend/add', // 添加好友
  DeleteFriend = '/friend/delete', // 删除好友
  handleApplication = '/friend/handleApplication', // 处理好友申请
  nearbyPublicFriendCounts = '/friend/nearby/count', // 附近豹友数量
  // nearbyFriendList = '/friend/public/list', // 附近豹友名单
  friendFroups = '/friend/groups', // 好友分组
  groupAdd = '/friend/group/add', // 添加好友分组
  updateFriendGroup = '/friend/group/update', // 修改好友分组
  deleteGroup = '/friend/group/delete' // 删除分组
}

/**
 * 好友列表
 */
export function friendList(data: unknown): Promise<FriendVO> {
  return http.get(Friend.friendList, data);
}

/**
 * 附近好友列表
 */
export function nearbyFriendList(data: unknown): Promise<FriendVO> {
  return http.get(Friend.nearbyFriendList, data);
}

/**
 * 公开豹友名单
 */
export function publicFriendList(data: unknown): Promise<FriendVO> {
  return http.get(Friend.publicFriendList, data);
}

/**
 * 好友添加
 */
export function friendAdd(data: unknown): Promise<any> {
  return http.post(Friend.friendAdd, data);
}

/**
 * 搜索好友
 */
export function searchFriend(data: unknown): Promise<any> {
  return http.get(Friend.searchFriend, data);
}

/**
 * 搜索公开豹友名单
 */
export function searchPublicFriend(data: unknown): Promise<any> {
  return http.get(Friend.searchPublicFriend, data);
}

/**
 * 获取好友申请列表
 */
export function applicationsFriends(): Promise<FriendVO> {
  return http.get(Friend.applications);
}

/**
 * 处理好友申请
 */
export function handleApplication(data: unknown): Promise<any> {
  return http.post(Friend.handleApplication, data);
}

/**
 * 附近豹友数量
 */
export function nearbyPublicFriendCounts(data: unknown): Promise<any> {
  return http.get(Friend.nearbyPublicFriendCounts, data);
}

/**
 * 备注
 */
export function friendRemark(data: unknown): Promise<any> {
  return http.put(Friend.remark, data);
}

export function deleteFriend(id: string): Promise<HttpResponse<any>> {
  return http.delete(Friend.DeleteFriend + '/' + id);
}

export function friendFroups(data: unknown): Promise<any> {
  return http.get(Friend.friendFroups, data);
}

export function groupAdd(data: unknown): Promise<any> {
  return http.post(Friend.groupAdd, data);
}

export function updateFriendGroup(data: unknown): Promise<any> {
  return http.post(Friend.updateFriendGroup, data);
}

export function deleteGroup(id: string): Promise<any> {
  return http.delete(Friend.updateFriendGroup + '/id');
}
